package com.belly.template.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

/**
 * @author Belly
 * @version 1.1.0
 */

@Getter
public enum FileFilterRuleEnum {

    CONTAINS("包含", "contains"),
    STARTS_WITH("前缀匹配", "startsWith"),
    ENDS_WITH("后缀匹配", "endsWith"),
    REGEX("正则", "regex"),
    EQUALS("相等", "equals");

    private final String text;
    private final String value;

    FileFilterRuleEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据值获得枚举
     * @param value
     * @return
     */
    public static FileFilterRuleEnum getEnumByValue(String value){
        if (ObjectUtil.isEmpty(value)){
            return null;
        }
        for (FileFilterRuleEnum ruleEnum : FileFilterRuleEnum.values()) {
            if (value.equals(ruleEnum.value)){
                return ruleEnum;
            }
        }
        return null;
    }
}
